<?php
/**
 * 根据课时获取所有购买该课程的学生信息
 * @author shej E-mail:28708@qq.com
 */
require_once '../../dz_framework/init.php';

$hid = isset($_REQUEST['hid'])?$_REQUEST['hid']:"";

$getVodId = DB::result_first("select v_id from ".DB::table('vod_hour')." where id='".$hid."'");

$getAllStudent = DB::fetch_all("select uid from ".DB::table("student_course")." where course_id='".$getVodId."' and course_flag=1 and course_cate=2");

if( $getAllStudent )
{
	foreach ( $getAllStudent as $key=>$value )
	{
		$userInfo = DB::fetch_first("select user_name,user_nickname,user_realname,gender,user_role_id from ".DB::table('users')." where user_id='".$value['uid']."'");
		$getAllStudent[$key]['user_name'] = $userInfo['user_name'];
		$getAllStudent[$key]['role_id'] = $userInfo['user_role_id'];
		$getAllStudent[$key]['user_nickname'] = $userInfo['user_nickname'];
		$getAllStudent[$key]['user_realname'] = $userInfo['user_realname'];
		$getAllStudent[$key]['gender'] = $userInfo['gender'];
	}
	
	echo json_encode( $getAllStudent ); exit;
}else{
	
	echo json_encode(array('error'=>'no student')); exit;
}